<template >
    <div>
        <h1>当前求和{{$store.state.sum}}</h1>
        <h2>当前求和乘以10倍{{$store.getters.bigSum}}</h2>
        <select v-model="n">
            <option :value="1">1</option>
            <option :value="2">2</option>
            <option :value="3">3</option>
        </select>
        <button @click="add">+</button>
        <button @click="sub">-</button>
        <button @click="addOdd">当前求和为奇数时再加</button>
        <button @click="addWait">等一等再加</button>
    </div>
</template>
<script>
export default {
    name:'Count',
    data() {
        return {
            n:1
        }
    },
    methods: {
        
        add(){
            //actions里没有逻辑的可以直接和mutations对话
            this.$store.commit('JIA',this.n)
        },
        sub(){
            //actions里没有逻辑的可以直接和mutations对话
            this.$store.commit('JIAN',this.n)
        },
        addOdd(){
            this.$store.dispatch('jiaOdd',this.n)
        },
        addWait(){
            this.$store.dispatch('jiaWait',this.n)
        }
    },
    mounted(){
        console.log('@@@',this)
    }
}
</script>
<style lang="css">
    button{
        margin-left: 5px;
    }
</style>